package org.boge.sharpdoc.controller;

import org.boge.sharpdoc.bean.LayuiReturnData;
import org.boge.sharpdoc.bean.SendMail;
import org.boge.sharpdoc.service.SendMailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

@Controller
@RequestMapping(value = "admin")
public class SendMailController {
    @Autowired
    private SendMailService sendMailService;

    @GetMapping("setEmailPage")
    public String setEmailPage(Model model) {
        model.addAttribute("current_email_info", sendMailService.getEmailInfo());
        return "admin/setEmail";
    }

    @ResponseBody
    @PostMapping("setEmail")
    public LayuiReturnData setEmail(SendMail mailInfo) {
        boolean success = sendMailService.updateEmail(mailInfo);
        return new LayuiReturnData(0, success);
    }
}